import React, {Component} from 'react';
import Item from "../item";
import './index.css'
import PropTypes from "prop-types";

class List extends Component {
    static propTypes = {
        updateTodos: PropTypes.func.isRequired,
        todos: PropTypes.array.isRequired,
        deleteTodo: PropTypes.func.isRequired
    }

    render() {
        const {todos, updateTodos, deleteTodo} = this.props
        return (
            <ul className="todo-main">
                {todos.map((todo) => {
                    return <Item key={todo.id} {...todo} updateTodos={updateTodos} deleteTodo={deleteTodo}/>
                })}
            </ul>
        );
    }
}

export default List;